<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>地区列表 - Powered By ${systemConfig.systemName}</title>
<meta name="Author" content="E-SHOP Team" />
<meta name="Copyright" content="E-SHOP" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<% include("/WEB-INF/views/common/include.html"){}%>
<link href="${base}/res/css/list.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${base}/res/js/list.js"></script>
<script type="text/javascript">
$().ready( function() {

	var $delete = $(".delete");
	
	// 地区删除
	$delete.click( function() {
		var $this = $(this);
		var id = $this.metadata().id;
        var shopId = $this.metadata().shopId;
		if (confirm("您确定要删除吗？") == true) {
			$.ajax({
				url: "${base}/area/delete",
				data: {"id": id},
				dataType: "json",
				async: false,
				success: function(data) {
					if (data.status == "success") {
						$this.parent().html("&nbsp;");
					}
					$.message(data.status, data.message);
				}
			});
		}
		return false;
	});
	
})
</script>
</head>
<body class="list">
	<div class="body">
		<div class="listBar">
			<h1><span class="icon">&nbsp;</span>地区管理&nbsp;<span class="pageInfo">总记录数: ${areaList.~size}</span></h1>
		</div>
		<form id="listForm" action="${base}/area/list" method="post">
			<div class="operateBar">
				<input type="button" class="addButton" onclick="location.href='${base}/area/add<%if(!isEmpty(parent.id)){%>?parentId=${parent.id!}<%}%>'" value="添加地区" />
			</div>
			<table class="listTable">
				<tr>
					<th colspan="5" class="green" style="text-align: center;">
						<%if (isEmpty(parent.id)){%>顶级地区<%}else{%>上级地区 - [${parent.name!}]<%}%>
					</th>
				</tr>
				<%for(list in areaList){%>
					<%if (listLP.index == 1){%>
						<tr>
					<%}%>										
							<td>
								<a href="${base}/area/list?parentId=${list.id}" title="查看下级地区">${list.name}</a>
								<a href="${base}/area/edit?id=${list.id}" title="编辑">[编辑]</a>
								<a href="#" class="delete {id: '${list.id}'}" title="删除">[删除]</a>
							</td>
							
					<%if ((listLP.index % 5) == 0 && listLP.last){%>
						</tr>
						<tr>
					<%}%>
					
					<%if (((listLP.index % 5) == 0) && !listLP.last){%>
						</tr>
					<%}%>
					
					
					
				<%}%>
				<%if (areaList.~size == 0){%>
					<tr>
						<td colspan="5" style="text-align: center; color: red;">
							无下级地区! <a href="${base}/area/add<%if (!isEmpty(parent.id)){%>?parentId=${parent.id!}<%}%>" style="color: gray">点击添加</a>
						</td>
					</tr>
				<%}%>
			</table>
			<%if (!isEmpty(parent.id)){%>
				<div class="blank"></div>
				<%if (!isEmpty(parent.parent_id)){%>
					<input type="button" class="formButton" onclick="location.href='${base}/area/list?parentId=${parent.parent_id!}'" value="上级地区" />
				<%}else{%>
					<input type="button" class="formButton" onclick="location.href='${base}/area/list'" value="上级地区" />
				<%}%>
			<%}%>
		</form>
	</div>
</body>
</html>